1 Imports System.Data.OleDb
2 Imports System.DateTime
3 Imports System.Math
4 Public Class Updatesss
5     Dim ConnString As String =
"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=CLInventory.accdb; Persist Security Info=False"
6     Dim OleDbConn As OleDbConnection = New OleDbConnection(ConnString)
7     Private Sub Updatesss_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
8         If Main_Form.ListView1.SelectedIndices.Count >
0 Then
9             Dim ItemNo As Integer = Main_Form.ListView1.SelectedIndices(
0)
10             Label1.Text = Main_Form.ListView1.Items(ItemNo).SubItems(
0).Text
11             TextBox1.Text = Main_Form.ListView1.Items(ItemNo).SubItems(
1).Text
12             TextBox2.Text = Main_Form.ListView1.Items(ItemNo).SubItems(
2).Text
13         Else
14         End If
15         Timer1.Enabled = True
16         Timer2.Enabled = True
17     End Sub
18     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
19         Label2.Text = DateAndTime.TimeOfDay
20     End Sub
21
22     Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
23         Label5.Text = DateAndTime.Today
24     End Sub
25
26     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
27         Dim id As String = Trim(Label1.Text)
28         Try
29             OleDbConn.Open()
30             Dim cmd2 As New OleDb.OleDbCommand(
"UPDATE Item_list SET Name_of_Item=M0, No_of_Item=M1 WHERE (ID=M2)", OleDbConn)
31             cmd2.Parameters.AddWithValue(
"M0", TextBox1.Text)
32             cmd2.Parameters.AddWithValue(
"M1", TextBox2.Text)
33             cmd2.Parameters.AddWithValue(
"M2", id)
34             cmd2.ExecuteNonQuery()
35             MsgBox(
"Successfully Updated!!")
36
37         Catch ex As Exception
38             MsgBox(ex.Message)
39         Finally
40             OleDbConn.Close()
41             
42         End Try
43         Main_Form.refreshing_utility()
44         Close()
45     End Sub
46
47     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
48         Close()
49     End Sub
50 End Class


Gõ tìm kiếm nhanh...